import {queryOrgTree} from "@/api/system/dept";
import {handleTree} from "@/utils/baseUtil";
import {isArr} from "@/utils/arrayUtil";

const getAreaData = () => {
  return new Promise((resolve, reject) => {
    queryOrgTree().then(response => {
      const areaData = response?.data ? handleTree(_.cloneDeep(response.data), "orgCode", 'parentCode') : [];
      const areaDataResult = isArr(areaData) ? areaData : []
      resolve({threeData: areaDataResult, baseData: _.cloneDeep(response?.data)})
    });
  })
}

export {getAreaData}
